using Microsoft.AspNetCore.Mvc;
using ZR.Model.ProdManage.Dto;
using ZR.Model.ProdManage;
using ZR.Service.ProdManage.IProdManageService;
using ZR.Admin.WebApi.Filters;

//创建时间：2025-05-18
namespace ZR.Admin.WebApi.Controllers.ProdManage
{
    /// <summary>
    /// 一级装箱明细
    /// </summary>
    [Verify]
    [Route("ProdManage/ProdOnePackDetail")]
    public class ProdOnePackDetailController : BaseController
    {
        /// <summary>
        /// 一级装箱明细接口
        /// </summary>
        private readonly IProdOnePackDetailService _ProdOnePackDetailService;

        public ProdOnePackDetailController(IProdOnePackDetailService ProdOnePackDetailService)
        {
            _ProdOnePackDetailService = ProdOnePackDetailService;
        }

        /// <summary>
        /// 查询一级装箱明细列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("pageList")]
        [ActionPermissionFilter(Permission = "prod:onePackDetail:list")]
        public IActionResult PageProdOnePackDetail([FromQuery] ProdOnePackDetailQueryDto parm)
        {
            var response = _ProdOnePackDetailService.GetPageList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询一级装箱明细详情
        /// </summary>
        /// <param name="DetailId"></param>
        /// <returns></returns>
        [HttpGet("{DetailId}")]
        [ActionPermissionFilter(Permission = "prod:onePackDetail:query")]
        public IActionResult GetProdOnePackDetail(string DetailId)
        {
            var response = _ProdOnePackDetailService.GetInfo(DetailId);
            
            var info = response.Adapt<ProdOnePackDetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加一级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "prod:onePackDetail:add")]
        [Log(Title = "一级装箱明细", BusinessType = BusinessType.INSERT)]
        public IActionResult AddProdOnePackDetail([FromBody] ProdOnePackDetailDto parm)
        {
            var modal = parm.Adapt<ProdOnePackDetail>().ToCreate(HttpContext);

            var response = _ProdOnePackDetailService.AddProdOnePackDetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新一级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "prod:onePackDetail:edit")]
        [Log(Title = "一级装箱明细", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateProdOnePackDetail([FromBody] ProdOnePackDetailDto parm)
        {
            var modal = parm.Adapt<ProdOnePackDetail>().ToUpdate(HttpContext);
            var response = _ProdOnePackDetailService.UpdateProdOnePackDetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除一级装箱明细
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete")]
        [ActionPermissionFilter(Permission = "prod:onePackDetail:delete")]
        [Log(Title = "一级装箱明细", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteProdOnePackDetail([FromBody] string[] ids)
        {
            return ToResponse(_ProdOnePackDetailService.Delete(ids));
        }

    }
}